<template>
      <div id="vipmanger">
            <page-title><span slot="pageName">技工管理</span></page-title>
            <!-- <div class="btnbox">
                  <el-button type="primary" @click="addMaster">添加创客二维码</el-button>
            </div> -->
            <!-- 表格 -->
              <el-table
                  :data="tableData"
                  style="width: 100%"
                  border
                  stripe
                  align="center"
                  :row-class-name="tableRowClassName">
                        <el-table-column
                              prop="userid"
                              align="center"
                              label="会员ID"
                              >
                        </el-table-column>
                        <el-table-column
                              prop="headimgurl"
                              align="center"
                              label="会员头像"
                              >
                              <template slot-scope="scope">
                                   <img :src="scope.row.headimgurl" alt="" width="50" height="50" >
                              </template>
                        </el-table-column>
                        <el-table-column
                              prop="wnickname"
                              align="center"
                              label="会员昵称">
                        </el-table-column>
                        <el-table-column
                              prop="addtime"
                              align="center"
                              label="注册时间">
                        </el-table-column>
                        <el-table-column
                              prop="phone"
                              align="center"
                              label="联系电话">
                        </el-table-column>

                        <el-table-column prop="cardNum" align="center" label="操作" width="300px">
                              <template slot-scope="scope">
                                    <el-button
                                    size="mini"
                                    type="primary"
                                    @click="showUser(scope.row.userid)">查看会员</el-button>
                                    <el-button
                                    size="mini"
                                    type="danger"
                                    @click="userEdit(scope.row)">修改</el-button>
                                    <el-button
                                    size="mini"
                                    type="success"
                                    @click="showTotal(scope.row)">数据统计</el-button>
                              </template>
                        </el-table-column>
                  </el-table>
            <!-- bianji -->
            <edit-info :DialogData="DialogData" :FormData="FormData" :disabled="disabled" @update="getAllManger"></edit-info>
          
      </div>
</template>

<script>
      import PageTitle from '@/components/PageTitle'
      import EditInfo from "@/components/main/EditInfo"
      // import AddMaster from "@/components/dialog/AddMaster"
      export default {
            data() {
                  return {
                        tableData: [
                             
                        ],
                        DialogData: {
                              show: false,
                        },
                        FormData: {},
                        disabled: {
                              username: true,
                              phone: true,
                              password: true,
                              shopname: true,
                              shopsite: true,
                              shoptime: true,
                        },
                        addData: {
                              show: false,
                              title: "添加技工"
                        }
                  }
            },
            components: {
                  PageTitle,
                  EditInfo,
                  
            },
            computed: {
                  token() {
                        return localStorage.miniToken 
                  }
            },
            mounted () {
                  this.getAllManger();
            },
            methods: {
                  // 查看店长下级会员
                  showUser( id ) {
                        this.$router.push(`/secondMenber/${id}`)
                  },
                  // 添加技工
                  addMaster() {
                        this.addData = {
                              show: true,
                              title: "添加创客"
                        }
                  },
                  // 编辑店长资料
                  userEdit( row ) {
                       // console.log(row);
                        
                        this.DialogData = {
                              show: true
                        }
                        this.FormData = {
                              userid: row.userid,
                              username: row.username,
                              password: row.password,
                              phone: row.phone,
                              shopsite: row.shopsite,
                              shopname: row.shopname,
                              shoptime: row.shoptime
                        }
                        this.disabled = {
                              username: true,
                              phone: true,
                              password: true,
                              shopname: true,
                              shopsite: true,
                              shoptime: true,
                        }
                  },
                  tableRowClassName({row, rowIndex}) {
                        if (rowIndex === 1) {
                              return 'warning-row';
                        } else if (rowIndex === 3) {
                              return 'success-row';
                        }
                              return '';
                  },
                  // 获取所有技工
                  async getAllManger() {
                        console.log(this.token);
                        
                        let res = await this.$axios.post("/admin/user/jigong", { token: this.token })
                       console.log(res);
                       
                        this.tableData = res.data.data
                  },
                  // 数据统计
                  async showTotal( row ) {
                        this.$router.push(`/total/${row.userid}`) 
                  },
            },
      }
</script>

<style lang="scss" scoped>
  .el-table .warning-row {
    background: oldlace;
  }

  .el-table .success-row {
    background: #f0f9eb;
  }
  .btnbox {
        width: 100%;
        padding: 20px;
        box-sizing: border-box;
        text-align: right;
  }
</style>